// JavaScript Document
$(document).ready(function(){
	$(document).on('click','#btn-add-price',function(){
		var duration = $('#duration').val();
		if(duration == null){
			$('#duration').focus();
			return false;	
		}
		var price = $('#price').val();
		/*if(price == ''){
			$('#price').focus();
			return false;	
		}*/
		var priceextension = $('#priceextension').val();
		var str = '<div class="price-row">';
		   str += '\n<div class="row-fluid">'; 
		   str += '\n\n<div class="span2">'; 
		   str += '<input type="text" name="Duration[]" class="span12" value="'+ duration +'" readonly />';
		   str += '\n\n</div>';
		   str += '\n\n<div class="span5">'; 
		   str += '<input type="text" name="Price[]" class="span12" value="'+ price +'" readonly />';
		   str += '\n\n</div>';
		   str += '\n\n<div class="span5">'; 
		   str += '<input type="text" name="PriceExtension[]" class="span12" value="'+ priceextension +'" readonly />';
		   str += '\n\n</div>';
		   str += '\n</div>';
		   str += '\n<button class="btn btn-mini btn-link btnDelete" value="Delete" name="delete_meta_btn">Delete</button>';
		   str += '<hr/>';
		   str += '\n</div>';
		$('#contain-new-price').append(str);
		$('#duration').val('');
		$('#price').val('');
		$('#priceextension').val('');
		return false;	
	});		
	$(document).on('click','.btnDelete',function(){
		$(this).parents('.price-row').remove();
		return false;
	});		   
});